@ECHO OFF

REM HSR patch by mkrsym1
REM https://notabug.org/mkrsym1/astra
REM mirror: https://codeberg.org/an-anime-team/astra

REM PLEASE AVOID EDITING THIS FILE
REM THERE IS A GOOD REASON TO BLOCK LOGGING SERVERS

SET perr1=1
SET perr2=1
SET perr=0

setlocal EnableDelayedExpansion
FOR /f "delims=" %%i IN ('ping -n 1 -w 1 log-upload.mihoyo.com') DO (
	echo %%i | find "[0.0.0.0]" >nul
	IF !ERRORLEVEL! EQU 0 SET "perr1=0"
	echo %%i | find "could not find host" >nul
	IF !ERRORLEVEL! EQU 0 SET "perr1=0"
)
FOR /f "delims=" %%i IN ('ping -n 1 -w 1 public-data-api.mihoyo.com') DO (
	echo %%i | find "[0.0.0.0]" >nul
	IF !ERRORLEVEL! EQU 0 SET "perr2=0"
	echo %%i | find "could not find host" >nul
	IF !ERRORLEVEL! EQU 0 SET "perr2=0"
)

IF %perr1% EQU 1 SET perr=1
IF %perr2% EQU 1 SET perr=1

IF %perr% NEQ 0 (
	echo Logging servers are reachable. Please edit your /etc/hosts to block them. See install.sh for the list >_error.txt
	notepad _error.txt
	del _error.txt
	exit
)

start StarRail.exe %*
